package jp.sourceforge.akjrcp.flvtools.basic;

import jp.sourceforge.akjrcp.akj_betas.Akj_betasPlugin;
import jp.sourceforge.akjrcp.akj_betas.Messages;

import org.eclipse.jface.preference.FieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.FileFieldEditor;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.preference.RadioGroupFieldEditor;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;


/**
 * This class represents a preference page that
 * is contributed to the Preferences dialog. By 
 * subclassing <samp>FieldEditorPreferencePage</samp>, we
 * can use the field support built into JFace that allows
 * us to create a page that is small and knows how to 
 * save, restore and apply itself.
 * <p>
 * This page is used to modify preferences only. They
 * are stored in the preference store that belongs to
 * the main plug-in class. That way, preferences can
 * be accessed directly via the preference store.
 */


public class FFMpegPage
	extends FieldEditorPreferencePage
	implements IWorkbenchPreferencePage {

	public static final int RATE_8000=8000;
	public static final int RATE_11025=11025;
	public static final int RATE_12000=12000;
	public static final int RATE_16000=16000;
	public static final int RATE_22050=22050;
	public static final int RATE_32000=32000;
	public static final int RATE_44100=44100;
	public static final int RATE_48000=48000;
	
    //public static final String EXPORT_WAVE_SAMPLEBIT = "export.wave.samplebit"; //$NON-NLS-1$
	public static final String EXPORT_WAVE_SAMPLERATE = "export.wave.samplerate"; //$NON-NLS-1$
	public static final String EXPORT_WAVE_CHANNEL = "export.wave.channel"; //$NON-NLS-1$
	
	//public static final String AC3_DEFAULT_BITRATE = "ac3DefaultBitrate";
	public static final String FFMPEG_PATH="ffmpeg_path"; //$NON-NLS-1$
    public static final String FFMPEG_OPTION="ffmpeg_option"; //$NON-NLS-1$
    public static final String AUDIO_BITRATE="audio_bitrate"; //$NON-NLS-1$
    public static final String VIDEO_BITRATE="video_bitrate"; //$NON-NLS-1$
    public static final String VIDEO_FPS="video_fps"; //$NON-NLS-1$
	public static final String VIDEO_CODEC = "video_codec";
	public static final String MPEG_TYPE = "mpeg_type";
	public static final String MPEG_TYPE_CBR = "mpeg_type_cbr";
	public static final String MPEG_TYPE_VBR = "mpeg_type_vbr";
	public static final String IMAGE_TIME = "image_time";
	public FFMpegPage() {
		super(GRID);
		setPreferenceStore(Akj_betasPlugin.getDefault().getPreferenceStore());
		setDescription(Messages.getString("ffmpeg_description")); //$NON-NLS-1$
		initializeDefaults();
	}
/**
 * Sets the default values of the preferences.
 */
	private void initializeDefaults() {
		
	}
	
/**
 * Creates the field editors. Field editors are abstractions of
 * the common GUI blocks needed to manipulate various types
 * of preferences. Each field editor knows how to save and
 * restore itself.
 */

	

    protected void createFieldEditors() {
    
        FileFieldEditor fileField=new FileFieldEditor(
                FFMPEG_PATH, Messages.getString("ffmpeg_path"),getFieldEditorParent()); //$NON-NLS-1$
        fileField.setFileExtensions(new String[]{"ffmpeg.exe"}); //$NON-NLS-1$
        addField(fileField);
        
        

    	addField(new IntegerFieldEditor(VIDEO_BITRATE,Messages.getString("video_bitrate"),getFieldEditorParent())); //$NON-NLS-1$
    	
    	addField(new StringFieldEditor(VIDEO_FPS,Messages.getString("video_fps"),getFieldEditorParent())); //$NON-NLS-1$
        
        
    
        
        
        addField(new RadioGroupFieldEditor(
		        EXPORT_WAVE_SAMPLERATE,
				Messages.getString("sample_rate"), // //$NON-NLS-1$
				4,
				new String[][] { { FFMpegPage.RATE_8000+" khz", FFMpegPage.RATE_8000+"" }, { //$NON-NLS-1$ //$NON-NLS-2$
					FFMpegPage.RATE_11025+" khz", FFMpegPage.RATE_11025+""   //$NON-NLS-1$ //$NON-NLS-2$
				    
				},
				{ FFMpegPage.RATE_12000+" khz", FFMpegPage.RATE_12000+"" }, //$NON-NLS-1$ //$NON-NLS-2$
				{ FFMpegPage.RATE_16000+" khz", FFMpegPage.RATE_16000+"" }, //$NON-NLS-1$ //$NON-NLS-2$
				{ FFMpegPage.RATE_22050+" khz", FFMpegPage.RATE_22050+"" }, //$NON-NLS-1$ //$NON-NLS-2$
				
				{ FFMpegPage.RATE_32000+" khz", FFMpegPage.RATE_32000+"" }, //$NON-NLS-1$ //$NON-NLS-2$
				{ FFMpegPage.RATE_44100+" khz", FFMpegPage.RATE_44100+"" }, //$NON-NLS-1$ //$NON-NLS-2$
				{ FFMpegPage.RATE_48000+" khz", FFMpegPage.RATE_48000+"" }, //$NON-NLS-1$ //$NON-NLS-2$
				
			}, getFieldEditorParent()));
        
		addField(new RadioGroupFieldEditor(
		        EXPORT_WAVE_CHANNEL,
			Messages.getString("channel"), //$NON-NLS-1$
			2,
			new String[][] { { Messages.getString("stereo"), "2" }, {Messages.getString("monoral") ,"1"}}, getFieldEditorParent())); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
       
		addField(new IntegerFieldEditor(AUDIO_BITRATE,Messages.getString("audio_bitrate"),getFieldEditorParent())); //$NON-NLS-1$
        
        addField(new StringFieldEditor(FFMPEG_OPTION,Messages.getString("ffmpeg_option"),getFieldEditorParent())); //$NON-NLS-1$
        
        addField(new StringFieldEditor(VIDEO_CODEC,Messages.getString("video_codec_text"),getFieldEditorParent())); //$NON-NLS-1$
        
        
        addField(new StringFieldEditor(IMAGE_TIME,Messages.getString("image_time_text"),getFieldEditorParent())); //$NON-NLS-1$
        
        addField(new RadioGroupFieldEditor(
		        MPEG_TYPE,
				Messages.getString("mpeg_type"), // //$NON-NLS-1$
				2,
				new String[][] { {"VBR",MPEG_TYPE_VBR},{"CBR",MPEG_TYPE_CBR}},getFieldEditorParent()));
        //addField(new IntegerFieldEditor(AC3_DEFAULT_BITRATE,"ac3 default bitrate",getFieldEditorParent()));
    }
	
	public void init(IWorkbench workbench) {
		IPreferenceStore store = getPreferenceStore();
		
	}
}